package com.by.yz.activity;

import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.provider.Settings;
import android.support.v7.app.AlertDialog;
import android.util.Log;
import android.view.View;
import android.widget.LinearLayout;

import android.widget.TextView;
import android.widget.RelativeLayout;

import com.android.volley.RequestQueue;
import com.android.volley.toolbox.ImageLoader;
import com.android.volley.toolbox.NetworkImageView;
import com.android.volley.toolbox.Volley;
import com.by.yz.App;
import com.by.yz.R;
import com.by.yz.activity.base.BaseActivity;
import com.by.yz.custom.CircleNetworkImageView;
import com.by.yz.entity.Doctorbean;
import com.by.yz.util.BitmapCache;
import com.by.yz.util.IsNetWork;

import static com.by.yz.App.imageLoader;
import static com.by.yz.App.requestQueue;


/**
 * Created by 你只能呵呵 on 2016/10/15.
 */

public class Famous_doctor_detail extends BaseActivity {
    LinearLayout tuwen_layout;
    CircleNetworkImageView doctor_image; //医生头像
    TextView famous_doctor_name_textview;//医生姓名
    TextView hospital_textview;//工作医院
    TextView keshi_textview;//隶属科室
    TextView touxian_textview;//职位
    RelativeLayout bt_detail;//医生详情
//    public static RequestQueue requestQueue;// 网络资源请求队列
//    public static ImageLoader imageLoader;// 图片加载类
    private static  ImageLoader.ImageListener listener;
    IsNetWork isNetWork;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        Log.e("onCreate", "onCreate");
        super.onCreate(savedInstanceState);
        setContentView(R.layout.famous_doctor_detail);
    }

    @Override
    protected void onStart() {
        super.onStart();
        Intent intent = this.getIntent();
        final Doctorbean team = (Doctorbean) intent.getSerializableExtra("Doctor");
        setToolbarTitle(team.getDoctorname() + "—" + team.getDepartment().getDepartment() + "诊所");
        if (isNetWork.isNetworkAvailable(this)) {
            doctor_image = (CircleNetworkImageView) findViewById(R.id.famous_doctor_image);
            doctor_image.setDefaultImageResId(R.mipmap.login_logo1);
            doctor_image.setErrorImageResId(R.mipmap.login_error);
            doctor_image.setImageUrl(team.getmImageView(), App.imageLoader);
            famous_doctor_name_textview = (TextView) findViewById(R.id.famous_doctor_name_textview);
            famous_doctor_name_textview.setText(team.getDoctorname());
            hospital_textview = (TextView) findViewById(R.id.hospital_textview);
            hospital_textview.setText(team.getTextHospital().getHospital());
            keshi_textview = (TextView) findViewById(R.id.keshi_textview);
            keshi_textview.setText(team.getDepartment().getDepartment());
            touxian_textview = (TextView) findViewById(R.id.touxian_textview);
            touxian_textview.setText(team.getPosition());

            tuwen_layout = (LinearLayout) findViewById(R.id.tuwen_layout);
            bt_detail = (RelativeLayout) findViewById(R.id.doctor_detail);

            tuwen_layout.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    Intent intent = new Intent(Famous_doctor_detail.this, ConsuiltActivity.class);
                    intent.putExtra("doctorid", team);
                    startActivity(intent);
                }
            });
            bt_detail.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {

                    Intent intent = new Intent(Famous_doctor_detail.this, DoctorIntroduct.class);
                    intent.putExtra("doctorid", team);
                    startActivity(intent);
                }
            });
        }else{
            //无网络连接情况
            new AlertDialog.Builder(Famous_doctor_detail.this)
                    .setTitle("提示!")
                    .setIcon(android.R.drawable.ic_dialog_info)
                    .setMessage("检测到您还没开启网络，请开启")
                    .setNegativeButton("取消", null)
                    .setPositiveButton("开启",
                            new DialogInterface.OnClickListener() {
                                @Override
                                public void onClick(DialogInterface dialog,
                                                    int which) {
                                    startActivity(new Intent(
                                            Settings.ACTION_WIRELESS_SETTINGS));// 进入无线网络配置界面
                                }
                            }).show();
        }
    }
}
